package com.example.order.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.example.order.R;
import com.example.order.adapter.TestAdapter;
import com.example.order.utils.Utils;

import java.util.ArrayList;
import java.util.List;

public class TestActivity extends AppCompatActivity {
    //内部类
    public static class Data{
        private String text1;
        private String text2;

        public String getText1() {
            return text1;
        }

        public void setText1(String text1) {
            this.text1 = text1;
        }

        public String getText2() {
            return text2;
        }

        public void setText2(String text2) {
            this.text2 = text2;
        }

        public Data() {
        }

        public Data(String text1, String text2) {
            this.text1 = text1;
            this.text2 = text2;
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        ListView listView=findViewById(R.id.list_test);
        List<Data> list=new ArrayList<>();
        for (int i = 1; i < 20; i++) {
            list.add(new Data(""+String.valueOf(i),"坚决拥护共产党"));
        }
        TestAdapter adapter=new TestAdapter(list, this, new TestAdapter.Callback() {
            @Override
            public void click(View v) {
                switch (v.getId())
                {
                    case R.id.test_button1:

                        Utils.showToast(TestActivity.this,"点击了+1",true);
                        break;
                    case R.id.test_button2:
                        Utils.showToast(TestActivity.this,"点击了-1",true);
                        break;
                }
            }
        });
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            }
        });
    }
}
